// 获取当前路由下面的子路由
let routeChildren = [];

async function getThisRouterSon(This) {
  routeChildren = [];
  const routes = This.$router.options.routes;
  const thisRoutePath = This.$route.path;
  await arrMap(routes, thisRoutePath)
  await setTimeoumy();
  return new Promise((resolve) => {
    resolve(routeChildren);
  })
}

async function setTimeoumy() {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve('ok');
    }, 400);
  })
}


async function arrMap(arr = [], parame) {
  for (let i = 0; i < arr.length; i++) {
    if (arr[i].path == parame) {
      routeChildren = arr[i].children || [];
      break;
    }
    if (arr[i].children) {
      arrMap(arr[i].children, parame)
    }
  }

}


export {
  getThisRouterSon
}
